package it.polimi.TravelDream.web.beans;

import java.util.List;

import it.polimi.TravelDream.ejb.dtos.HotelDTO;
import it.polimi.TravelDream.ejb.dtos.RoomDTO;
import it.polimi.TravelDream.ejb.eaos.RoomList;

import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

@ManagedBean(name = "room")
@SessionScoped
public class RoomBean {
	
	@EJB
	private RoomList roomList;
	
	private RoomDTO currentRoom = new RoomDTO();
	private HotelDTO currentHotel = new HotelDTO();
	
	private List<HotelDTO> hotelsDTO;
	
	public RoomBean() {
		this.currentRoom = new RoomDTO();
		this.currentHotel = new HotelDTO();
	}
	
	public String searchHotelAndGoToCreate() {
		hotelsDTO = roomList.searchHotels();
		return "room?faces-redirect=true";
	}
	
	public String GoToSearchRoom() {
		return "search room?faces-redirect=true";
	}
	
	public String create(HotelDTO hotelDTO) {
		this.currentHotel = hotelDTO;
		roomList.add(currentRoom, currentHotel);
		return "home?faces-redirect=true";
	}
	
	public RoomList getRoomList() {
		return roomList;
	}

	public void setRoomList(RoomList roomList) {
		this.roomList = roomList;
	}

	public RoomDTO getCurrentRoom() {
		return currentRoom;
	}

	public void setCurrentRoom(RoomDTO currentRoom) {
		this.currentRoom = currentRoom;
	}

	public HotelDTO getCurrentHotel() {
		return currentHotel;
	}

	public void setCurrentHotel(HotelDTO currentHotel) {
		this.currentHotel = currentHotel;
	}

	public List<HotelDTO> getHotelsDTO() {
		return hotelsDTO;
	}

	public void setHotelsDTO(List<HotelDTO> hotelsDTO) {
		this.hotelsDTO = hotelsDTO;
	}
	
}
